/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   Module Name          : com.yaodian100.crm.cs.web.BulletinAction
   Module Description   :

   Date Created      : 2010/1/26
   Original Author   : andy.chuang
   Team              : yaodian100
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   MODIFICATION HISTORY
   ------------------------------------------------------------------------------
   Date Modified       Modified by       Comments
   ------------------------------------------------------------------------------
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
package com.yaodian100.crm.cs.web;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.annotation.Resource;

import com.yaodian100.core.admin.utils.AdminHelper;
import com.yaodian100.core.common.service.BaseManager;
import com.yaodian100.crm.cs.entity.Bulletin;

/**
 * @author andy.chuang
 *
 */
public class BulletinAction {
    private String id;
    private String announceDate;
    private String effectedService;
    private String effectScope;
    private String expectFixDate;
    private String knownDescription;
    private String occurDate;
    private String realReason;
    private String reason;
    private String solvedDate;
    private String type;
    private String iamlazy;
    private String name;
    private String AJAX;
    @Resource
    private BaseManager baseMgr;
    public String page(){
	if(AJAX!=null && AJAX.equals("true")){
	    return iamlazy+"_ajax";
	}else{
	    return iamlazy;
	}
    }
    public String update(){
	try {
	    SimpleDateFormat sdf=new SimpleDateFormat("yyyy/MM/dd HH:mm");
	    Date date=new Date();
	    Bulletin bulletin=null;
	    if(id!=null && id.length()>0){
	        //update
	        bulletin=(Bulletin)baseMgr.get(Bulletin.class, Long.parseLong(id));
	        
	    }else{
	        bulletin=new Bulletin();
	        bulletin.setCreateDate(date);
	        bulletin.setCreateUser(AdminHelper.getUserDetails().getUsername());
	    }
	    bulletin.setModifyUser(AdminHelper.getUserDetails().getUsername());
	    bulletin.setAnnounceDate(sdf.parse(announceDate));
	    bulletin.setEffectedService(effectedService);
	    bulletin.setEffectScope(effectScope);
	    bulletin.setExpectFixDate(sdf.parse(expectFixDate));
	    bulletin.setKnownDescription(knownDescription);
	    bulletin.setOccurDate(sdf.parse(occurDate));
	    bulletin.setRealReason(realReason);
	    bulletin.setReason(reason);
	    bulletin.setSolvedDate(sdf.parse(solvedDate));
	    bulletin.setType(type);
	    bulletin.setName(name);
	    baseMgr.saveOrUpdate(bulletin);
	    
	    
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new RuntimeException(e);
	}
	return "updateBulletin";
    }
    public String delete(){
	if(id!=null && id.length()>0){
	    Bulletin bulletin=(Bulletin)baseMgr.get(Bulletin.class, Long.parseLong(id));
	    baseMgr.delete(bulletin);
	}
	return "list";
    }
    /**
     * @return the id
     */
    public String getId() {
        return id;
    }
    /**
     * @param id the id to set
     */
    public void setId(String id) {
        this.id = id;
    }
    /**
     * @return the announceDate
     */
    public String getAnnounceDate() {
        return announceDate;
    }
    /**
     * @param announceDate the announceDate to set
     */
    public void setAnnounceDate(String announceDate) {
        this.announceDate = announceDate;
    }
    /**
     * @return the effectedService
     */
    public String getEffectedService() {
        return effectedService;
    }
    /**
     * @param effectedService the effectedService to set
     */
    public void setEffectedService(String effectedService) {
        this.effectedService = effectedService;
    }

    /**
     * @return the effectScope
     */
    public String getEffectScope() {
        return effectScope;
    }
    /**
     * @param effectScope the effectScope to set
     */
    public void setEffectScope(String effectScope) {
        this.effectScope = effectScope;
    }
    /**
     * @return the expectFixDate
     */
    public String getExpectFixDate() {
        return expectFixDate;
    }
    /**
     * @param expectFixDate the expectFixDate to set
     */
    public void setExpectFixDate(String expectFixDate) {
        this.expectFixDate = expectFixDate;
    }
    /**
     * @return the knownDescription
     */
    public String getKnownDescription() {
        return knownDescription;
    }
    /**
     * @param knownDescription the knownDescription to set
     */
    public void setKnownDescription(String knownDescription) {
        this.knownDescription = knownDescription;
    }
    /**
     * @return the occurDate
     */
    public String getOccurDate() {
        return occurDate;
    }
    /**
     * @param occurDate the occurDate to set
     */
    public void setOccurDate(String occurDate) {
        this.occurDate = occurDate;
    }
    /**
     * @return the realReason
     */
    public String getRealReason() {
        return realReason;
    }
    /**
     * @param realReason the realReason to set
     */
    public void setRealReason(String realReason) {
        this.realReason = realReason;
    }
    /**
     * @return the reason
     */
    public String getReason() {
        return reason;
    }
    /**
     * @param reason the reason to set
     */
    public void setReason(String reason) {
        this.reason = reason;
    }
    /**
     * @return the solvedDate
     */
    public String getSolvedDate() {
        return solvedDate;
    }
    /**
     * @param solvedDate the solvedDate to set
     */
    public void setSolvedDate(String solvedDate) {
        this.solvedDate = solvedDate;
    }
    /**
     * @return the type
     */
    public String getType() {
        return type;
    }
    /**
     * @param type the type to set
     */
    public void setType(String type) {
        this.type = type;
    }
    /**
     * @return the iamlazy
     */
    public String getIamlazy() {
        return iamlazy;
    }
    /**
     * @param iamlazy the iamlazy to set
     */
    public void setIamlazy(String iamlazy) {
        this.iamlazy = iamlazy;
    }
    /**
     * @return the name
     */
    public String getName() {
        return name;
    }
    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }
    /**
     * @return the aJAX
     */
    public String getAJAX() {
        return AJAX;
    }
    /**
     * @param aJAX the aJAX to set
     */
    public void setAJAX(String aJAX) {
        AJAX = aJAX;
    }
}
